<template>
  <view>
    <TabBar :activeIndex="1"></TabBar>
    <view class="right-content">
      <view class="tit">会议</view>
	  <scroll-view scroll-y class="page" lower-threshold='50' @scrolltolower="scrolltolower"
	    upper-threshold='50'>
		  <meeting-list
			@meetingItemClick="goMeetingDetail"
			:meetingList="meetingList"
		  ></meeting-list>
	   </scroll-view>
      <view v-show="isLoadMore">
        <uni-load-more :status="loadStatus"></uni-load-more>
      </view>
    </view>
  </view>
</template>

<script>
import meetingList from "../../components/meeting-list/meeting-list.vue";
import request from "../../utils/request.js";
export default {
  data() {
    return {
      meetingList: [],
      page: 1,
      pagesize: 10,
      loadStatus: "loading", //加载样式：more-加载前样式，loading-加载中样式，nomore-没有数据样式
      isLoadMore: false, //是否加载中
    };
  },
  onLoad() {
    this.getMeetingList();
  },
  onPullDownRefresh() {
	console.log("onPullDownRefresh")
	this.getMeetingList();
	uni.stopPullDownRefresh();
  },
  components: { "meeting-list": meetingList },
  methods: {
	scrolltolower() {
	    //上拉触底函数
	    if (!this.isLoadMore) {
		  //此处判断，上锁，防止重复请求
		  this.isLoadMore = true;
		  this.page += 1;
		  this.getMeetingList();
		}
    },
    // 获取会议列表数据
    async getMeetingList() {
      // const res = await request({
      // 	url: '/api/getMeetingList?page='+this.page+'&pagesize='+this.pagesize
      // }).then(response => {
      //   if(res.data.code==200){
      // 	if(res.data.message){
      // 		  this.meetingList=this.meetingList.concat(res.data.message)
      // 		  if(res.data.message.length<this.pagesize){  //判断接口返回数据量小于请求数据量，则表示此为最后一页
      // 				this.isLoadMore=true
      // 				this.loadStatus='nomore'
      // 		  }else{
      // 				this.isLoadMore=false
      // 		  }
      // 	}else{
      // 		  this.isLoadMore=true
      // 		  this.loadStatus='nomore'
      // 	}
      //   }else{  //接口请求失败的处理
      // 		uni.showToast({title:res.data.msg,icon:'none'})
      // 		this.isLoadMore=false
      // 		if(this.page>1){
      // 			this.page-=1
      // 		}
      //   }
      // }).catch(error => {
      //   uni.showToast({title: '服务器开小差了，请您稍后再试！',icon:'none'})
      //   this.isLoadMore=false
      //   if(this.page>1){
      // 		this.page-=1
      //   }
      // })

      for (let i = 0; i < 10; i++) {
        var str = [];
        var Chars = "0123456789abcdefghijklmnopqrstuvwxyz";
        for (var j = 0; j < 36; j++) {
          str[j] = Chars.substr(Math.floor(Math.random() * 16), 1);
        }
        str[0] = str[8] = str[13] = str[18] = str[23] = "-";
        let UUID = "tabName" + str.join("");
        this.meetingList.push({
          id: UUID,
          meetingName: "2022年董事会第一次会议" + i,
          meetingStartTime: "2022-02-12 10:23:25",
          meetingFinishTime: "2022-02-12 12:23:25",
          meetingType: "临时会议",
        });
      }
      this.isLoadMore = false;
    },
    // 导航到会议详情页
    goMeetingDetail(id) {
      console.log("跳转");
      uni.navigateTo({
        url: "/pages/meeting-detail/meeting-detail?id=" + id,
        animationType: "none",
      });
    },
  },
};
</script>

<style lang="scss">
@import "@/static/css/_px2vw.scss";
.tit {
  height: vw(50);
  line-height: vw(50);
  text-align: center;
  background-color: rgb(64, 158, 255);
  font-size: vw(20);
  color: #ffffff;
  font-family: "Arial Negreta", "Arial Normal", "Arial", sans-serif;
  font-weight: 700;
  font-style: normal;
  & + .page {
    height: 92.2vh;
  }
}
</style>
